package com.ywk.miaohsa.service;

import com.ywk.miaohsa.dao.GoodsDao;
import com.ywk.miaohsa.redis.RedisService;
import com.ywk.miaohsa.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {

    @Autowired
    GoodsDao goodsDao;

    public List<GoodsVo> getGoodsList(){
        return goodsDao.getGoodsList();
    }

    public GoodsVo getGoodsVoByGoodsId(long goodsId) {
        return goodsDao.getGoodsVoByGoodsId(goodsId);
    }

    public boolean reduceStock(GoodsVo goods) {
        long goodsId=goods.getId();
        return goodsDao.reduceStock(goodsId) > 0;
    }
}
